package com.ohc.leetcode.字符串;

// 2022年4月13日14:30:49
public class 替换空格05 {
    public static String replaceSpace(String s) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if ((s.toCharArray()[i] + "").equals(" ")) {
                builder.append("%20");
            } else {
                builder.append(s.toCharArray()[i]);
            }
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        String str = "We are happy.";
        String s = replaceSpace(str);
        System.out.println(s);
    }
}
